|
|
|
|
|
|
|
When the user highlights some text in a text box, he or she should be able to press one of the controls on the toolbar to have that text copied to, cut to, or pasted from the Clipboard. Heres the code in the toolbar that makes sure the user can only perform these operations from a text box control: |
|
|
|
 |
|
|
|
|
Private Sub tlbTools_ButtonClick(ByVal Button As _
ComctlLib.Button) If TypeOf Screen.ActiveControl Is TextBox Then If Button.Key = "Cut" Then
Clipboard.SetText Screen.ActiveControl.SelText Screen.ActiveControl.Text = ""
ElseIf Button.Key = "Copy" Then
Clipboard.SetText Screen.ActiveControl.SelText ElseIf Button.Key = "Paste" Then
Screen.ActiveControl.SelText = Clipboard.GetText
End If
End If
End Sub |
|
|
|
|
|
|
|
|
Notice the use of the TypeOf operator in this code. The TypeOf operator is used to determine the type of control. If its a text box, you can run the code you learned about in the previous section. |
|
|
|
|
|
|
|
|
Creating New Forms at Runtime |
|
|
|
|
|
|
|
|
In many Windows applications, you have the ability to open many instances of the same form. For example, in Word, you may have many different documents open, or in Excel, you can have many spreadsheets open. Each of these documents are not separate formsthey are just instances of one particular Form object. |
|
|
|
|
|
|
|
|
Lets program the same type of functionality using the Employee Information form. Figure 21.7 shows you a list box filled with employees. If you select one, you can click on the Edit button to display the full information for that employee. Once you click the Edit button, the screen shown in Figure 21.8 will be displayed. |
|
|
|
|
|
|
|
|
Examples Filename: EmpList.frm |
|
|
|
|
|